Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rpmsgfs/rpmsgfs_client.c:774:3: warning: 'strcpy' writing 1 or more bytes into a region of size 0 overflows the destination #5823

Merged
merged 1 commit into from
Mar 23, 2022

Conversation

xiaoxiang781216
Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 commented Mar 22, 2022

Summary

Found by change #5476.

Impact

Minor, fix warning

Testing

Pass CI

…re bytes into a region of size 0 overflows the destination

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
@@ -740,8 +741,8 @@ int rpmsgfs_client_rename(FAR void *handle, FAR const char *oldpath,

DEBUGASSERT(len <= space);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When DEBUGASSERT is a no-op, this check for buffer overflow will not exist.

I suggest:

if (len > space)
  {
    return -ENOMEM;
  }

provided space is number of bytes we can actually use. If require one more byte, use >= instead:

if (len >= space)
  {
    return -ENOMEM;
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't rpmsg_free_tx_payload_buffer api yet:
OpenAMP/open-amp#361
That is why DEBUGASSERT is added here since we can't return the buffer to pool without sending.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once OpenAMP/open-amp#361 get fixed, we can convert all DEBUGASSERT to if/else.

fs/rpmsgfs/rpmsgfs_client.c Show resolved Hide resolved
@pkarashchenko pkarashchenko merged commit 4d8c926 into apache:master Mar 23, 2022
@xiaoxiang781216 xiaoxiang781216 deleted the warn2 branch March 23, 2022 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants